package com.amazon.shop.exception;

import com.amazon.shop.bean.enums.ResultEnum;
import lombok.Getter;
import lombok.Setter;

/**
 * 创建时间：10:33 2021/1/13
 *
 * @author lzj
 * @since JDK 1.8.0_171
 * 类说明：
 * <p>
 * Modification History:
 * Date         Author          Version            Description
 * ---------------------------------------------------------*
 */
@Setter
@Getter
public class BusinessException extends RuntimeException {
    private String code;
    private String servecode;
    private String msg;
    private Object data;

    public BusinessException(ResultEnum resultEnum){
        super(resultEnum.getMsg());
        this.msg = resultEnum.getMsg();
        this.code = resultEnum.getCode();
        this.servecode = resultEnum.getServecode();
    }

    public BusinessException(ResultEnum resultEnum, Object data){
        super(resultEnum.getMsg());
        this.msg = resultEnum.getMsg();
        this.code = resultEnum.getCode();
        this.servecode = resultEnum.getServecode();
        this.data = data;
    }

    public BusinessException(String code, String servecode, String message) {
        super(message);
        this.msg = message;
        this.code = code;
        this.servecode = servecode;
    }

    public BusinessException(String code, String servecode, String message, Object data) {
        super(message);
        this.msg = message;
        this.code = code;
        this.servecode = servecode;
        this.data = data;
    }
}
